#include <stdio.h>

#define LIST_SIZE(arr) (sizeof(arr) / sizeof(*arr))

void handleShow(char *str)
{
    printf("this is show : %s\n", str);
}

void handleSet(char *str)
{
    printf("this is set : %s\n", str);
}

enum type
{
    TYPE_SHOW = 0,
    TYPE_SET,
};

typedef struct BaseHandle
{
    int type;
    void (*handle)(char *str);
} BaseHandle_t;

const BaseHandle_t BaseHandleArr[] = {
    {.type = TYPE_SHOW,
     .handle = handleShow},
    {.type = TYPE_SET,
     .handle = handleSet}};

void commonHandle(int type, char *str)
{
    // 添加处理的相同部分

    for (int i = 0; i < LIST_SIZE(BaseHandleArr); i++)
    {
        if (type == BaseHandleArr[i].type)
        {
            BaseHandleArr[i].handle(str);
        }
    }

    // 添加处理的相同部分
}

int main()
{
    commonHandle(TYPE_SHOW, "show");
    commonHandle(TYPE_SET, "set");

    return 0;
}